import React, { Component } from "react";

import withPortal from "./withPortal";

// import { createPortal } from "react-dom";

// portal可以将元素或者组件渲染到项目的任意地方去
// ReactDOM.createPortal, 接收两个参数 组件或者元素 需要挂载的dom节点
class Child extends Component {
  render() {
    return <div>child</div>;
  }
}

const Child2 = withPortal(Child);

class App extends Component {
  state = {};
  render() {
    return (
      <div className="portal">
        <h3>portal</h3>
        <Child2 />
      </div>
    );
  }
}

export default App;
